/**
 * $Id$
 *
 */
package com.csoa.community.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.csoa.community.R;

/**
 * @Title: GalleryIndexMyFocusBaikeAdapter.java
 * @Copyright: Copyright (c) 2005
 * @Description: <br>
 * <br>
 * @Company: ��������
 * @Created on 2012-1-9 ����04:08:03
 */
public class GalleryAdapter extends ArrayAdapter<String> {
	private int select = 1;

	public int getCount() {
		// TODO Auto-generated method stub
		return super.getCount();
	}

	public GalleryAdapter(Context context,
			List<String> appListData) {
		super(context, 0, appListData);
	}

	@Override
	public String getItem(int position) {
		return super.getItem(position);
	}

	@Override
	public long getItemId(int position) {
		return super.getItemId(position);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Activity activity = (Activity) getContext();

		final String s = getItem(position);
		LayoutInflater inflater = activity.getLayoutInflater();
		View rowView = inflater.inflate(
				R.layout.adapter_official_gallery__item, null);
		TextView tv = (TextView) rowView.findViewById(R.id.txt_gallery_type_title);
		if (select == position) {
			tv.setText(s);
//			tv.setTextColor(R.color.darkblue);
			tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0,
					R.drawable.bg_gallery_type_selected);
		}else{
			tv.setText(s);
//			tv.setTextColor(R.color.gray);
			tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
			
		}
		return rowView;
	}

	public void notifyDataSetChanged(int albumId) {

		select = albumId;

		super.notifyDataSetChanged();

	}

	/* ���ݾ��������λ���� ����getScale����views�Ĵ�С(0.0f to 1.0f) */
	public float getScale(boolean focused, int offset) {
		return Math.max(0, 1.0f / (float) Math.pow(2, Math.abs(offset)));
	}
}
